﻿@using KhuyenMaiVang.HtmlHelpers

@model IEnumerable<KhuyenMaiVang.DAL.Voucher>
@foreach (var v in Model)
{ 
    <div class="deal-box-item">
        
        <div class="deal-title">
            <h2>@Html.ActionLink(v.Title, "VoucherDetail", "Home", new { id = v.ID },null)</h2>
        </div>
        <div class="deal-box-image">
            @Html.ImageLink("VoucherDetail", "Home", v.Thumb, v.Title, new { id = v.ID })
        </div>
        <div class=".deal-box-description">
            <p>@truncate(@v.Description, 100)</p>
        </div>
        <div class="voucher-price-info">
            <div class="button-view">@Html.ActionLink(" ",  "VoucherDetail","Home", new { id = v.ID }, null)</div>
            <div class="voucher-price">
                <span class="voucher-sell">@v.SellPrice.Value.ToString("#,#.###")&nbsp;VND</span>
                <br />
                Giá gốc : <span class="voucher-costprice">@v.CostPrice&nbsp;VND</span>
            </div>
            <div style="clear:left"></div>
        </div>
        <div class="voucher-buy">
            <div class="price-save">
              <span class="voucher-buy-column-title">Tiết kiệm</span> <br />
              <span class="voucher-buy-column-value">@( ((1- v.SellPrice/v.CostPrice)*100).Value.ToString("#,#.#"))%</span>
            </div>
            <div class="voucher-had-bought">
               <span class="voucher-buy-column-title">Số người đã mua</span><br/>
               <span class="voucher-buy-column-value"></span>
            </div>
            <div class="voucher-timeout">
                @{
                    TimeSpan timeout = (v.EndTime.Value - DateTime.Now);
                }
                <span class="voucher-buy-column-title">Thời gian còn lại</span><br/>
                <span class="clockCountDown" d="@timeout.Days" h="@timeout.Hours" m="@timeout.Minutes" s="@timeout.Seconds" ms="@timeout.Milliseconds" >@(timeout.Days + " : " + timeout.Hours + " : " + timeout.Minutes +" : "+ timeout.Seconds)</span>
            </div>
            <div style="clear:both"></div>
        </div>
    </div>
}
<div style="clear: both">
</div>

@helper truncate(String s, int maxlength)
    {
  /*      int len = s.Length;
        String view = s.Substring(0, Math.Min(s.Length, maxlength));
        if (len > maxlength)
        {
            view += "...";
        }
   */
   @Html.Raw( s);
}